#include <stdio.h>
#include <stdlib.h>
#include "list.h"

int main(void)
{
        list *node = NULL;
        score tmp;
        for (int i = 0; i < 3; i++) //链表存储对象为结构体
        {
                tmp.id = i;
                snprintf(tmp.name, NAMESIZE, "stu%d", i);
                tmp.math = rand() % 100;
                tmp.chinese = rand() % 100;
                // int ret = list_insert_forword(&node, &tmp);
                int ret = list_insert_backword(&node, &tmp);
                if (ret != 0)
                        exit(0);
        }

        printf("插入操作结果:\n");
        list_show(node);

        list_delete(&node);
        printf("删除操作结果:\n");
        list_show(node);

        printf("查找操作结果:\n");
        score *ptr;
        ptr = list_find(node, 1);
        if (ptr == NULL)
                fprintf(stderr, "Can not find!\n");
        else
                printf("%d %s %d %d\n", ptr->id, ptr->name, ptr->math, ptr->chinese);

        list_destory(&node);
        list_show(node);

        return 0;
}
